package com.lz.wsy.controller;

import com.lz.utils.Result;
import com.lz.wsy.pojo.Brand;
import com.lz.wsy.pojo.Notice;
import com.lz.wsy.service.BrandService;
import com.lz.wsy.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/brand")
public class BrandController {

    @Autowired
    private BrandService brandService;


    /** 查询所有数据 */
    @GetMapping("/list")
    public Result list(){
        return Result.success(brandService.list());
    }


    /** 通过主键查询单条公司品牌 */
    @GetMapping("/get/{brandId}")
    public Result get(@PathVariable("brandId") Integer brandId){
        return Result.success(brandService.get(brandId));
    }

    /** 新增或者编辑公司品牌 */
    @PostMapping("/save")
    public Result save(@RequestBody Brand brand){
        return Result.success(brandService.addAndEdit(brand));
    }


    /** 删除单条数据 */
    @PostMapping("/remove")
    public Result delete(@RequestParam("brandId") Integer brandId){
        return Result.success(brandService.delBrand(brandId));
    }

}













